package com.fr.lintcode;

import java.util.List;

public class Q920 {
	/**
	 * @param intervals: an array of meeting time intervals
	 * @return: if a person could attend all meetings
	 */
	public boolean canAttendMeetings(List<Interval> intervals) {
		// Write your code here
		for(int i = 0; i < intervals.size(); i++) {
			Interval interval = intervals.get(i);
			for(int j = i+1; j < intervals.size(); j++) {
				Interval t = intervals.get(j);
//				if((t.end > interval.start && t.end < interval.end) ||(interval.end > interval.start && t.end < t.end)) {
//					return false;
//				}
				if(t.start > interval.start) {
					if(interval.end > t.start) {
						return false;
					}
				}else if(t.start == interval.start) {
					return false;
				}else {
					if(t.end > interval.start) {
						return false;
					}
				}
			}
		}
		return true;
	}
	public class Interval {
		int start, end;

		Interval(int start, int end) {
			this.start = start;
			this.end = end;
		}
	}
}

